%% US Public Debt and Safe Asset Market Power
%% Jason Choi, Rishabh Kirpalani, and Diego Perez
%% Nov 24, 2024

%% Solve Domestic Fringe Equilibrium

%----------------------------------------------------------------
% 0. Housekeeping
%----------------------------------------------------------------

close all

%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------

// Endogenous Variables
var b bf rb rkstar rk krw_star kus_star krw kus kstar k wstar w c_rw c_us drdb spread vrw vus y dMrwdb;

// Exogenous Variables
var nnu oomega oomegaf A Astar;

// Shocks
varexo eps_nnu eps_oomega eps_A;

// Paramters
parameters ggamma bbeta eeta llambda llambdaf aalpha Astarbar Abar iiota iiota_star ddelta_rw ddelta_us
  nnu_bar oomega_bar oomegaf_bar rrho_nnu rrho_oomega rrho_oomegaf ssigma_nnu ssigma_oomega ssigma_oomegaf rrho_A ssigma_A rrho_Astar ssigma_Astar
  b_me b_df bf_df spread_df
  rb_df rkstar_df rk_df krw_star_df kus_star_df krw_df kus_df kstar_df k_df
  capKstar_df capK_df wstar_df w_df crw_df cus_df y_df;

%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

% // Parameters

ggamma = 2;
bbeta = 0.9875;
eeta = 0.545;
llambda = 1;
aalpha = 0.3;
Astarbar = 0.9254;
Abar = 0.8154;
iiota = 0.9070;
iiota_star = 0.7939;
ddelta_rw = 0.1;
ddelta_us = 0.1;
nnu_bar = 0.0068;
oomega_bar = 0.0082;
rrho_nnu = 0.99;
ssigma_nnu = 0.04;
rrho_oomega = 0.95;
ssigma_oomega = 0.32;
llambdaf = 1;
oomegaf_bar = 0.0068;
rrho_oomegaf = rrho_oomega;
ssigma_oomegaf = 0.16;
rrho_A = 0.95;
ssigma_A = 0.04;
rrho_Astar = rrho_A;
ssigma_Astar = ssigma_A;

% // Numerical Steady state for debt (Domestic fringe)

b_me = (oomega_bar/(nnu_bar*eeta))^(1/(eeta-1-llambda));
bf_me = (oomegaf_bar/(nnu_bar*eeta))^(1/(eeta-1-llambdaf));
[res,err_df] = fsolve(@(s) df_obj(s, eeta, llambda, nnu_bar, oomega_bar, llambdaf, oomegaf_bar), [b_me, bf_me])
b_df = res(1);
bf_df = res(2);

% // Analytic Steady State (Domestic fringe)
rb_df = 1/bbeta - nnu_bar*(b_df + bf_df)^(eeta-1) - 1;
rkstar_df = 1/bbeta	+ ddelta_rw - 1;
rk_df = 1/bbeta	+ ddelta_us - 1;
krw_star_df = ((aalpha*(1-iiota_star)*Astarbar*((1/bbeta+ddelta_rw-1)/(aalpha*iiota_star*Astarbar))^((aalpha*(1-iiota_star)-1)/(aalpha*(1-iiota_star))))/(1/bbeta+ddelta_us-1))^((aalpha*(1-iiota_star))/(1-aalpha));
kus_star_df = ((1/bbeta+ddelta_rw-1)/(aalpha*iiota_star*Astarbar))^(1/(aalpha*(1-iiota_star)))*krw_star_df^((1-iiota_star*aalpha)/(aalpha*(1-iiota_star)));
krw_df = ((aalpha*iiota*Abar*((1/bbeta+ddelta_us-1)/(aalpha*(1-iiota)*Abar))^((aalpha*iiota-1)/(aalpha*iiota)))/(1/bbeta+ddelta_rw-1))^((aalpha*iiota)/(1-aalpha));
kus_df = ((1/bbeta+ddelta_us-1)/(aalpha*(1-iiota)*Abar))^(1/(aalpha*iiota))*krw_df^((1-(1-iiota)*aalpha)/(aalpha*iiota));
kstar_df = krw_star_df + krw_df;
k_df = kus_star_df + kus_df;
capKstar_df = krw_star_df^iiota_star*kus_star_df^(1-iiota_star);
capK_df = krw_df^(1-iiota)*kus_df^iiota;
wstar_df = Astarbar*(1-aalpha)*(capKstar_df)^aalpha;
w_df = Abar*(1-aalpha)*(capK_df)^aalpha;
crw_df = wstar_df + (rkstar_df-ddelta_rw)*kstar_df + nnu_bar/eeta*(b_df + bf_df)^eeta + rb_df*(b_df + bf_df);
cus_df = w_df + (rk_df-ddelta_us)*k_df - oomega_bar/(1+llambda)*(b_df)^(1+llambda) - rb_df*(b_df+bf_df) - oomegaf_bar/(1+llambdaf)*(bf_df)^(1+llambdaf);
drdb_df = -nnu_bar*(eeta-1)*(b_df+bf_df)^(eeta-2);
dMrwdb_df = 0;
nnu_df = nnu_bar;
oomega_df = oomega_bar;
oomegaf_df = oomegaf_bar;
A_df = Abar;
Astar_df = Astarbar;
spread_df = (rk_df-ddelta_us-rb_df);
vrw_df = crw_df^(1-ggamma)/(1-ggamma)/(1-bbeta);
vus_df = cus_df^(1-ggamma)/(1-ggamma)/(1-bbeta);
y_df = A_df*(kus_df^iiota*krw_df^(1-iiota))^aalpha;

%----------------------------------------------------------------
% 3. Model
%----------------------------------------------------------------

model;

rk-ddelta_rw-rb = (oomegaf*(bf)^(llambdaf));

c_rw^(-ggamma) = bbeta*c_rw(+1)^(-ggamma)*(nnu*(b+bf)^(eeta-1)+1+rb);
c_rw^(-ggamma) = bbeta*c_rw(+1)^(-ggamma)*(1-ddelta_rw+rkstar);
c_rw + kstar + b + bf = wstar + (1-ddelta_rw+rkstar(-1))*kstar(-1) + nnu(-1)/eeta*(b(-1)+bf(-1))^eeta + (1+rb(-1))*(b(-1)+bf(-1));

c_us^(-ggamma) * (1+(nnu*(eeta-1)*(b+bf)^(eeta-2)/(oomegaf*llambdaf*(bf)^(llambdaf-1)-nnu*(eeta-1)*(b+bf)^(eeta-2)))) = bbeta*c_us(+1)^(-ggamma)*(oomega*(b)^(llambda)+oomegaf*(bf)^(llambdaf)*(nnu*(eeta-1)*(b+bf)^(eeta-2)/(oomegaf*llambdaf*(bf)^(llambdaf-1)-nnu*(eeta-1)*(b+bf)^(eeta-2)))+(1+rb)*(1+(nnu*(eeta-1)*(b+bf)^(eeta-2)/(oomegaf*llambdaf*(bf)^(llambdaf-1)-nnu*(eeta-1)*(b+bf)^(eeta-2))))+(drdb*(1+(nnu*(eeta-1)*(b+bf)^(eeta-2)/(oomegaf*llambdaf*(bf)^(llambdaf-1)-nnu*(eeta-1)*(b+bf)^(eeta-2)))))*(b+bf));
c_us^(-ggamma) = bbeta*c_us(+1)^(-ggamma)*(1-ddelta_us+rk);
c_us + k - b - bf = w + (1-ddelta_us+rk(-1))*k(-1) - oomega(-1)/(1+llambda)*(b(-1))^(1+llambda) - oomegaf(-1)/(1+llambdaf)*(bf(-1))^(1+llambdaf) - (1+rb(-1))*(b(-1)+bf(-1));

rk = Astar*aalpha*(1-iiota_star)*krw_star^(aalpha*iiota_star)*kus_star^(aalpha*(1-iiota_star)-1);
rkstar = Astar*aalpha*iiota_star*krw_star^(aalpha*iiota_star-1)*kus_star^(aalpha*(1-iiota_star));
rk = A*aalpha*iiota*krw^(aalpha*(1-iiota))*kus^(aalpha*iiota-1);
rkstar = A*aalpha*(1-iiota)*krw^(aalpha*(1-iiota)-1)*kus^(aalpha*iiota);
wstar = Astar*(1-aalpha)*krw_star^(aalpha*iiota_star)*kus_star^(aalpha*(1-iiota_star));
w = A*(1-aalpha)*krw^(aalpha*(1-iiota))*kus^(aalpha*iiota);

0 = -(drdb+nnu*(eeta-1)*(b+bf)^(eeta-2))*(c_rw(+1)/c_rw)^(-ggamma)+(1+rb+nnu*(b+bf)^(eeta-1))*dMrwdb;
0 = dMrwdb*(rkstar+1-ddelta_rw);

k = kus + kus_star;
kstar = krw + krw_star;

log(nnu) = (1-rrho_nnu)*log(nnu_bar) + rrho_nnu*log(nnu(-1)) + ssigma_nnu*eps_nnu;
log(oomega) = (1-rrho_oomega)*log(oomega_bar) + rrho_oomega*log(oomega(-1)) + ssigma_oomega*eps_oomega;
log(oomegaf) = (1-rrho_oomegaf)*log(oomegaf_bar) + rrho_oomegaf*log(oomegaf(-1)) + ssigma_oomegaf*eps_oomega;
log(A) = (1-rrho_A)*log(Abar) + rrho_A*log(A(-1)) + ssigma_A*eps_A;
log(Astar) = (1-rrho_Astar)*log(Astarbar) + rrho_Astar*log(Astar(-1)) + ssigma_Astar*eps_A;

spread = (rk-ddelta_us-rb);

vrw = c_rw^(1-ggamma)/(1-ggamma) + bbeta*vrw(+1);
vus = c_us^(1-ggamma)/(1-ggamma) + bbeta*vus(+1);

y = A*(kus^iiota*krw^(1-iiota))^aalpha;

end;

%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------

initval;
  bf = bf_df;
  b = b_df;
  rb = rb_df;
  rkstar = rkstar_df;
  rk = rk_df;
  krw_star = krw_star_df;
  kus_star = kus_star_df;
  krw = krw_df;
  kus = kus_df;
  kstar = kstar_df;
  k = k_df;
  wstar = wstar_df;
  w = w_df;
  c_rw = crw_df;
  c_us = cus_df;
  drdb = drdb_df;
  dMrwdb = dMrwdb_df;
  nnu = nnu_df;
  oomega = oomega_df;
  oomegaf = oomegaf_df;
  A = A_df;
  Astar = Astar_df;
  spread = spread_df;
  vrw = vrw_df;
  vus = vus_df;
  y = y_df;
end;

resid;
check;

shocks;
  var eps_nnu = 1;
  var eps_oomega = 1;
  var eps_A = 1;
end;

set_dynare_seed('default');
steady;
stoch_simul(order=2,noprint,nograph,periods=100000,pruning);

%----------------------------------------------------------------
% 5. Generate moments
%----------------------------------------------------------------

spread_path = (rk-ddelta_us-rb)*100;
var_sp = var(spread_path);
auto_sp = autocorr(spread_path);
cost = oomega./(1+llambda).*(b).^(1+llambda);
benefit = (eeta-1).*b.*(log(b)-nnu);
var_by = var(b./y);
auto_by = autocorr(b./y);
corr_pq_by = corr(spread_path,b./y);
corr_qqf_by = corr(b./y,bf./y);
corr_pqf_by = corr(spread_path,bf./y);
auto_bfy = autocorr(bf./y);
profits_gov = mean((rk-ddelta_us-rb).*b - oomega./(1+llambda).*(b).^(1+llambda));
profits_fringe = mean((rk-ddelta_us-rb).*bf - oomegaf./(1+llambdaf).*(bf).^(1+llambdaf));
home_bias = mean(kus./(kus+kus_star));
nfa = - b + kus_star - krw;
nfa_y = nfa./y;
NFA_us = mean(nfa_y);
gdp_ratio = mean((Astar.*(krw_star).^(aalpha*iiota_star).*(kus_star).^(aalpha*(1-iiota_star)))./(A.*(kus).^(aalpha*iiota).*(krw).^(aalpha*(1-iiota))));

moments = [mean(b./y) mean(bf./y) mean(spread_path) var_by var_sp corr_pq_by auto_by(2) auto_sp(2) corr_qqf_by auto_bfy(2) profits_gov profits_fringe home_bias NFA_us gdp_ratio]'; 
data_mom = [0.41 0.82 0.62 0.03 0.086 -0.56 0.96 0.70 0.51 0.99 99999 99999 0.8 -0.05 1.1]';
rowNames = {'Mean b/y','Mean bf/y','Mean sp','Var b/y','Var sp','Corr (b/y,sp)','Autocorr b/y','Autocorr sp','Corr (b/y,bf/y)','Autocorr bf/y','Profits Gov','Profits Fringe','Home Bias','NFA','GDP Ratio'};
colNames = {'Model Moments','Data Moments'};
TableA0 = array2table([moments data_mom],'RowNames',rowNames,'VariableNames',colNames)

deficit = cost(1:end-1) + b(2:end) - (1+rb(1:end-1)).*b(1:end-1);
deficit_y = deficit./y(1:end-1);
ca = -(b(2:end)-b(1:end-1)) + kus_star(2:end)-kus_star(1:end-1) - (krw(2:end)-krw(1:end-1));
ca_y = ca./y(1:end-1);
var_ca_y = var(ca_y);
var_nfa_y = var(nfa_y);
var_deficit_y = var(deficit_y);
corr_nfa_y = corr(nfa_y,b./y);
corr_ca_def_y = corr(ca_y,deficit_y);

moments = [mean(rb) var(rb)*100 var_ca_y*100 var_nfa_y var_deficit_y corr_nfa_y corr_ca_def_y]';
data_mom = [0.0053 0.00097*100 0.00033*100 0.035 0.002 -0.654 -0.207]';
rowNames = {'Mean rb (Targeted)','Var rb(x100)','Var CA(x100)','Var NFA','Var Deficit','Corr(NFA,b)','Corr(CA,deficit)'};
colNames = {'Model Moments','Data Moments'};
TableA0 = array2table([moments data_mom],'RowNames',rowNames,'VariableNames',colNames)

%----------------------------------------------------------------
% 6. Calculate welfare from transition
%---------------------------------------------------------------

b_smef = mean(b);
bf_smef = mean(bf);
rb_smef = mean(rb);
spread_smef = mean(spread);

vus_me = vus_df;
vrw_me = vrw_df;
cus_me = cus_df;
crw_me = crw_df;

%----------------------------------------------------------------
% 6. Calculate welfare from transition
%---------------------------------------------------------------

oo_mef = oo_;
M_mef = M_;
options_mef = options_;

save me_fringe_save oo_mef vus_me vrw_me cus_me crw_me M_mef options_mef b_smef bf_smef spread_smef rb_smef;

load ce_fringe_save;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulated 2nd Order Welfare
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Stochastic - lag issue fixed
NN = 100000;
BB = 5000;
NN_BB = NN+BB;

vrw_pos = strmatch('vrw',M_.endo_names,'exact');
vus_pos = strmatch('vus',M_.endo_names,'exact');

% Simulate CE
shock_matrix = randn(M_.exo_nbr,NN_BB);
sim_eq_ce_ergo = simult_(M_cef,options_cef,oo_cef.dr.ys,oo_cef.dr,shock_matrix',options_cef.order);
sim_eq_ce_ergo = sim_eq_ce_ergo(:,BB+2:end); % burn

% CE to ME
shock_matrix = zeros(M_.exo_nbr,2);
for ii=1:NN
  sim_eq_ce = simult_(M_cef,options_cef,sim_eq_ce_ergo(:,ii),oo_cef.dr,shock_matrix',options_cef.order);
  vrw_sce(ii) = sim_eq_ce(vrw_pos,2);
  vus_sce(ii) = sim_eq_ce(vus_pos,2);
end
for ii=1:NN
  sim_eq_me = simult_(M_mef,options_mef,sim_eq_ce_ergo(:,ii),oo_mef.dr,shock_matrix',options_mef.order);
  vrw_ce_me_sim(ii) = sim_eq_me(vrw_pos,2);
  vus_ce_me_sim(ii) = sim_eq_me(vus_pos,2);
end

upsilon_us_transition2 = mean(((vus_ce_me_sim./vus_sce).^(1/(1-ggamma)) - 1)*100)
upsilon_rw_transition2 = mean(((vrw_ce_me_sim./vrw_sce).^(1/(1-ggamma)) - 1)*100)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fileID = fopen('params_fringe.tex','w');
ddata = [bbeta, aalpha, ggamma, ddelta_us, eeta, iiota, log(nnu_bar), iiota_star, ssigma_nnu, rrho_nnu, Abar, llambda, Astarbar, log(oomega_bar), ssigma_A, ssigma_oomega, rrho_A, ssigma_oomega llambdaf, log(oomegaf_bar), ssigma_oomegaf, rrho_oomegaf]';
fprintf(fileID,'\\begin{tabular}{>{\\centering}p{1.5cm}c>{\\centering}p{1.5cm}>{\\centering}p{0.4cm}>{\\centering}p{1.5cm}c>{\\centering}p{1.5cm}} \n \\toprule \n \\multicolumn{3}{c}{Panel A: Households} &  & \\multicolumn{3}{c}{Panel B: Firms}\\tabularnewline \n \\midrule \n Param. & Description & Value &  & Param. & Description & Value\\tabularnewline \n \\midrule \n $\\beta${\\small{}\\vspace{.4em}} & Discount rate & $%5.4f$ &  & $\\alpha$ & Capital share & $%2.1f$\\tabularnewline \n $\\gamma${\\small{}\\vspace{.4em}} & Risk aversion & $%1.0f$ &  & $\\delta$ & Depreciation rate & $%2.1f$\\tabularnewline \n $\\eta${\\small{}\\vspace{.4em}} & Benefit elasticity & $%4.3f$ &  & $\\iota$ & US own capital share & $%3.2f$\\tabularnewline \n $\\bar{\\nu}${\\small{}\\vspace{.4em}} & Benefit parameter & $%3.2f$ &  & $\\iota^{*}$ & RoW own capital share & $%3.2f$\\tabularnewline \n $\\sigma_{\\nu}${\\small{}\\vspace{.4em}} & Benefit volatility & $%3.2f$ &  & $\\theta$ & Capital substitutability & $1$\\tabularnewline \n $\\rho_{\\nu}${\\small{}\\vspace{.4em}} & Benefit persistence & $%3.2f$ &  & $\\bar{A}$ & US productivity & $%3.2f$\\tabularnewline \n $\\lambda${\\small{}\\vspace{.4em}} & US cost elasticity & $%1.0f$ &  & $\\bar{A^{*}}$ & RoW productivity & $%3.2f$\\tabularnewline \n $\\bar{\\omega}${\\small{}\\vspace{.4em}} & US cost parameter & $%3.2f$ &  & $\\sigma_{A}$ & Productivity volatility & $%3.2f$\\tabularnewline \n $\\sigma_{\\omega}${\\small{}\\vspace{.4em}} & US cost volatility & $%3.2f$ &  & $\\rho_{A}$ & Productivity persistence & $%3.2f$\\tabularnewline \n $\\rho_{\\omega}${\\small{}\\vspace{.4em}} & Cost persistence & $%3.2f$ &  &  &  & \\tabularnewline \n $\\lambda${\\small{}\\vspace{.4em}} & Fringe cost elasticity & $%1.0f$ &  &  &  & \\tabularnewline \n $\\bar{\\omega}${\\small{}\\vspace{.4em}} & Fringe cost parameter & $%3.2f$ &  &  &  & \\tabularnewline \n $\\sigma_{\\omega}${\\small{}\\vspace{.4em}} & Fringe cost volatility & $%3.2f$ &  &  &  & \\tabularnewline \n $\\rho_{\\omega}${\\small{}\\vspace{.4em}} & Fringe cost persistence & $%3.2f$ &  &  &  & \\tabularnewline \n \\bottomrule \n \\end{tabular}',ddata);
fclose(fileID);

fileID = fopen('moms_fringe.tex','w');
ddata = [0.53, mean(rb)*100, 0.03, var_ca_y*100, 0.41, mean(b./y), 0.002, var_deficit_y, 0.62, mean(spread_path), -0.65, corr_nfa_y, 0.03, var_by, -0.21, corr_ca_def_y, 0.086, var_sp, -0.56, corr_pq_by, 0.96, auto_by(2), 0.71, auto_sp(2), 0.82, mean(bf./y), 0.51, corr_qqf_by, 0.99, auto_bfy(2), 0.8, home_bias, -0.05, NFA_us, 1.1, gdp_ratio]';  
fprintf(fileID,'\\begin{tabular}{>{\\centering}p{5.2cm}>{\\centering}p{1.3cm}>{\\centering}p{1.3cm}>{\\centering}p{0.05cm}>{\\centering}p{4.25cm}>{\\centering}p{1.3cm}>{\\centering}p{1.3cm}} \n \\toprule \n \\multicolumn{3}{c}{Panel A: Targeted moments} &  & \\multicolumn{3}{c}{Panel B: Untargeted moments}\\tabularnewline \n \\midrule \n Moments & Data & Model &  & Moments & Data & Model\\tabularnewline \n \\midrule \n $\\text{Mean}\\left(\\text{interest rate}\\right)${\\small{}\\vspace{.4em}} & $%3.2f\\%%$ & $%3.2f\\%%$ &  & $\\text{Var\\ensuremath{\\left(\\text{CA}\\right)}}$ & $%3.2f$ & $%3.2f$\\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{public debt}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  & $\\text{Var\\ensuremath{\\left(\\text{fiscal deficit}\\right)}}$ & $%4.3f$ & $%4.3f$\\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{convenience yield}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f\\%%$ & $%3.2f\\%%$ &  & $\\text{Corr\\ensuremath{\\left(\\text{public debt,NFA}\\right)}}$ & $%3.2f$ & $%3.2f$\\tabularnewline \n $\\text{Var\\ensuremath{\\left(\\text{\\text{public debt}}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  & $\\text{Corr\\ensuremath{\\left(\\text{CA,fiscal deficit}\\right)}}$ & $%3.2f$ & $%3.2f$\\tabularnewline \n $\\text{Var\\ensuremath{\\left(\\text{convenience yield}\\right)}}${\\small{}\\vspace{.4em}} & $%4.3f$ & $%4.3f$ &  &  &  & \\tabularnewline \n $\\text{Corr\\ensuremath{\\left(\\text{public debt, conv. yield}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Autocorr\\ensuremath{\\left(\\text{public debt}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Autocorr\\ensuremath{\\left(\\text{convenience yield}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{private safe asset}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Corr\\ensuremath{\\left(\\text{private safe asset, conv. yield}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Autocorr\\ensuremath{\\left(\\text{private safe asset}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{asset home bias}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{NFA}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n $\\text{Mean\\ensuremath{\\left(\\text{US-RoW GDP ratio}\\right)}}${\\small{}\\vspace{.4em}} & $%3.2f$ & $%3.2f$ &  &  &  & \\tabularnewline \n \\bottomrule \n \\end{tabular}',ddata);
fclose(fileID);
